package com.javaDemo.designpattern.springguanchazhe;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;

public class EmailService implements ApplicationListener<UserRegisterEvent> { // <1>
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Override
    @Async// <3>
    public void onApplicationEvent(UserRegisterEvent event) { // <2>
        logger.info("[onApplicationEvent][给用户({}) 发送邮件]", event.getUsername());
    }
}